Hello and welcome to this demonstration on creating
a loop in a flowchart. In this video, you will learn to create a workflow
that will repeatedly ask the user for an input until the input given
is an even number. Let's begin. Search for a flowchart activity in the activities panel and drag and drop it in
the designer panel. Rename the flowchart
activity as loop in flowchart and add an
annotation to it. Double-click to view
the flowchart activity. Search for an input
dialog activity in the activities panel, and drag and drop it on the start nodes down arrow in the flowchart container to
connect it to the node. Rename the activity
as even number. Double-click to open it. In double-quotes,
enter the title text, even number in the
dialogue title, and label text, enter an even number in
the input label box. From the variables panel, create a variable int even number with
variable type as int 32. Scope its flowchart,
loop in flowchart. Close the variables panel. Go to the Properties panel of the user input dialog activity, and enter the variable int even number in its
result property. Navigate back to the flowchart. Search for a flow
decision activity in the activities panel, and drag and drop it below
the input dialog activity. Rename the flow decision
activity as even number. Navigate to the properties panel of the flow decision activity. Click the condition fields
ellipsis icon to open the expression editor window
and enter the condition int even number mod
two equal to zero. Click "Okay". Next, insert
two message box activities. Place one on the left, that is the true side, and another on the right, that is the false side of the flow decision activity,
rename both activities. Double-click to view the
first message box activity. In the text area,
enter text, perfect. Navigate back to the flowchart. Double-click to view
the second message box activity in the text area. Enter the text, try again. Navigate back to the flowchart. To create a loop connect
a node of the message box odd number activity with
the input dialog activity. This makes sure that
the user is prompted to enter a number until an
even number is entered. Save the project and run it. Let's test the code
with a few variations. Try three and click "Okay". It is an odd number. Try five and click "Okay". It is also an odd number. In both the cases, the program runs a loop and asks for another input by displaying, try again. Try 14. As it is an even number, the message perfect appears on the screen and
the process ends. It is encouraged to build
the workflow as demonstrated and try creating loops of your choice using this activity. Thank you for watching.